// @author: caoshi
// @date: 2021-05-21 12:53
package domain

import "fmt"

type Grade struct {
	Id        string `json:"id" db:"id"`
	StuName   string `json:"stuName" db:"stuName"`
	Chinese   int    `json:"chinese" db:"chinese"`
	Math      int    `json:"math" db:"math"`
	English   int    `json:"english" db:"english"`
	Physics   int    `json:"physics" db:"physics"`
	Chemistry int    `json:"chemistry" db:"chemistry"`
	Biology   int    `json:"biology" db:"biology"`
	Total     int    `json:"total" db:"total"`
}

func (g *Grade) SumTotalGrade() {
	g.Total = g.Chinese + g.Math + g.English +
		g.Physics + g.Chemistry + g.Biology
}

type Col struct {
	Prop  string `json:"prop"`
	Label string `json:"label"`
	Width int    `json:"width"`
}

// 打印切片元素
func PrintGrades(grades []Grade) {
	for _, item := range grades {
		fmt.Println(item.Id, item.StuName, item.Chinese, item.Math, item.English,
			item.Physics, item.Chemistry, item.Biology)
	}
}
